home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / patch.arc / CONFIGUR < prev    next >
Encoding:
Text File  |  1988-07-20  |  16.0 KB  |  676 lines

  1. #! /bin/sh
  2. #
  3. # If these # comments don't work, trim them.  Don't worry about any other
  4. # shell scripts, Configure will trim # comments from them for you.
  5. #
  6. # Note: if you are running ksh, be sure to say "sh Configure".
  7. #
  8. # (If you are trying to port this package to a machine without sh, I would
  9. # suggest you cut out the prototypical config.h from the end of Configure
  10. # and edit it to reflect your system.  Some packages may include samples
  11. # of config.h for certain machines, so you might look for one of those.)
  12. #
  13. # $Header: Configure,v 2.0 86/09/17 15:32:58 lwall Exp $
  14. #
  15. # $Log:    Configure,v $
  16. # Revision 2.0  86/09/17  15:32:58  lwall
  17. # Baseline for netwide release.
  18. #
  19. # Yes, you may rip this off to use in other distribution packages.
  20. #
  21. # (Note: this Configure script was generated automatically.  Rather than
  22. # working with this copy of Configure, you may wish to get metaconfig.)
  23.  
  24. define='define'
  25. undef='/*undef'
  26.  
  27. d_eunice=''
  28. eunicefix=''
  29. loclist=''
  30. expr=''
  31. sed=''
  32. echo=''
  33. cat=''
  34. rm=''
  35. mv=''
  36. cp=''
  37. tail=''
  38. tr=''
  39. mkdir=''
  40. sort=''
  41. uniq=''
  42. grep=''
  43. trylist=''
  44. test=''
  45. inews=''
  46. egrep=''
  47. more=''
  48. pg=''
  49. Mcc=''
  50. vi=''
  51. mailx=''
  52. Log=''
  53. Header=''
  54. bin=''
  55. cc=''
  56. contains=''
  57. cpp=''
  58. d_index=''
  59. d_void=''
  60. iandd=''
  61. libc=''
  62. mansrc=''
  63. manext=''
  64. n=''
  65. c=''
  66. package=''
  67. registers=''
  68. reg1=''
  69. reg2=''
  70. reg3=''
  71. reg4=''
  72. reg5=''
  73. reg6=''
  74. reg7=''
  75. reg8=''
  76. reg9=''
  77. reg10=''
  78. reg11=''
  79. reg12=''
  80. reg13=''
  81. reg14=''
  82. reg15=''
  83. reg16=''
  84. spitshell=''
  85. shsharp=''
  86. sharpbang=''
  87. startsh=''
  88. CONFIG=''
  89.  
  90. package=patch
  91.  
  92. echo "Beginning of configuration questions for $package kit."
  93. : Eunice requires " " instead of "", can you believe it
  94. echo " "
  95.  
  96. : sanity checks
  97. PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc'
  98. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0; kill $$)
  99.  
  100. if test ! -t 0; then
  101.     echo "Say 'sh Configure', not 'sh <Configure'"
  102.     exit 1
  103. fi
  104.  
  105. : some greps do not return status, grrr.
  106. echo "grimblepritz" >grimble
  107. if grep blurfldyick grimble >/dev/null 2>&1 ; then
  108.     contains=contains
  109. else
  110.     if grep grimblepritz grimble >/dev/null 2>&1 ; then
  111.     contains=grep
  112.     else
  113.     contains=contains
  114.     fi
  115. fi
  116. rm -f grimble
  117. : the following should work in any shell
  118. case "$contains" in
  119. contains*)
  120.     echo " "
  121.     echo "AGH!  Grep doesn't return a status.  Attempting remedial action."
  122.     cat >contains <<'EOSS'
  123. grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
  124. EOSS
  125. chmod 755 contains
  126. esac
  127.  
  128. : first determine how to suppress newline on echo command
  129. echo "Checking echo to see how to suppress newlines..."
  130. (echo "hi there\c" ; echo " ") >.echotmp
  131. if $contains c .echotmp >/dev/null 2>&1 ; then
  132.     echo "...using -n."
  133.     n='-n'
  134.     c=''
  135. else
  136.     echo "...using \\\c"
  137.     echo "c."
  138.     n=''
  139.     c='\c'
  140. fi
  141. echo $n "Type carriage return to continue.  Your cursor should be here-->$c"
  142. read ans
  143. rm -f .echotmp
  144.  
  145. : now set up to do reads with possible shell escape
  146. : if this does not work on your machine, 1,$ s/. myread/read ans/
  147. cat <<EOSC >myread
  148. ans='!'
  149. while expr "X\$ans" : "X!" >/dev/null; do
  150.     read ans
  151.     case "\$ans" in
  152.     !)
  153.     sh
  154.     echo " "
  155.     echo $n "\$rp $c"
  156.     ;;
  157.     !*)
  158.     set \`expr "X\$ans" : "X!\(.*\)\$"\`
  159.     sh -c "\$*"
  160.     echo " "
  161.     echo $n "\$rp $c"
  162.     ;;
  163.     esac
  164. done
  165. rp='Your answer:'
  166. EOSC
  167.  
  168. : general instructions
  169. cat <<EOH
  170.  
  171. This installation shell script will examine your system and ask you questions
  172. to determine how $package and any auxiliary files should be installed.  If you
  173. get stuck on a question, you may use a ! shell escape to start a subshell or
  174. execute a command.  Many of the questions will have default answers in
  175. square brackets--typing carriage return will give you the default.
  176.  
  177. On some of the questions which ask for file or directory names you are
  178. allowed to use the ~name construct to specify the login directory belonging
  179. to "name", even if you don't have a shell which knows about that.  Questions
  180. where this is allowed will be marked "(~name ok)".
  181. EOH
  182. rp="[Type carriage return to continue]"
  183. echo $n "$rp $c"
  184. . myread
  185. cat <<EOH
  186. Much effort has been expended to ensure that this shell script will run
  187. on any Unix system.  If despite that it blows up on you, your best bet is
  188. to edit Configure and run it again.  (Trying to install this package
  189. without having run Configure may be well nigh impossible.)  Also, let me
  190. (lwall@sdcrdcf.UUCP) know how I blew it.
  191.  
  192. This installation script affects things in two ways: 1) it may do direct
  193. variable substitutions on some of the files included in this kit, and
  194. 2) it builds a config.h file for inclusion in C programs.  You may edit
  195. any of these files as the need arises after running this script.
  196.  
  197. EOH
  198. rp="[Type carriage return to continue]"
  199. echo $n "$rp $c"
  200. . myread
  201.  
  202. : get old answers, if there is a config file out there
  203. if test -f config.sh; then
  204.     echo " "
  205.     rp="I see a config.sh file.  Did Configure make it on THIS system? [y]"
  206.     echo $n "$rp $c"
  207.     . myread
  208.     case "$ans" in
  209.     n*) echo "OK, I'll ignore it.";;
  210.     *)  echo "Fetching default answers from your old config.sh file..."
  211.         . config.sh
  212.     ;;
  213.     esac
  214. fi
  215.  
  216. : get list of predefined functions in a handy place
  217. echo " "
  218. if test -f /lib/libc.a; then
  219.     echo "Your C library is in /lib/libc.a.  You're normal."
  220.     libc=/lib/libc.a
  221. else
  222.     if test -f /usr/lib/libc.a; then
  223.     echo "Your C library is in /usr/lib/libc.a, of all places."
  224.     libc=/usr/lib/libc.a
  225.     else
  226.     if test -f "$libc"; then
  227.         echo "Your C library is in $libc, like you said before."
  228.     else
  229.         cat <<'EOM'
  230.  
  231. I can't seem to find your C library.  I've looked for /lib/libc.a and
  232. /usr/lib/libc.a, but neither of those are there.  What is the full name
  233. EOM
  234.         echo $n "of your C library? $c"
  235.         rp='C library full name?'
  236.         . myread
  237.         libc="$ans"
  238.     fi
  239.     fi
  240. fi
  241. echo " "
  242. echo $n "Extracting names from $libc for later perusal...$c"
  243. if ar t $libc > libc.list; then
  244.     echo "done"
  245. else
  246.     echo " "
  247.     echo "The archiver doesn't think $libc is a reasonable library."
  248.     exit 1
  249. fi
  250.  
  251. : make some quick guesses about what we are up against
  252. echo " "
  253. echo $n "Hmm...  $c"
  254. if $contains SIGTSTP /usr/include/signal.h >/dev/null 2>&1 ; then
  255.     echo "Looks kind of like a BSD system, but we'll see..."
  256.     echo exit 0 >bsd
  257.     echo exit 1 >usg
  258.     echo exit 1 >v7
  259. else
  260.     if $contains fcntl libc.list >/dev/null 2>&1 ; then
  261.     echo "Looks kind of like a USG system, but we'll see..."
  262.     echo exit 1 >bsd
  263.     echo exit 0 >usg
  264.     echo exit 1 >v7
  265.     else
  266.     echo "Looks kind of like a version 7 system, but we'll see..."
  267.     echo exit 1 >bsd
  268.     echo exit 1 >usg
  269.     echo exit 0 >v7
  270.     fi
  271. fi
  272. if $contains vmssystem libc.list >/dev/null 2>&1 ; then
  273.     cat <<'EOI'
  274. There is, however, a strange, musty smell in the air that reminds me of
  275. something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
  276. EOI
  277.     echo "exit 0" >eunice
  278.     eunicefix=unixtovms
  279.     d_eunice="$define"
  280. : it so happens the Eunice I know will not run shell scripts in Unix format
  281. else
  282.     echo " "
  283.     echo "Congratulations.  You aren't running Eunice."
  284.     eunicefix=':'
  285.     d_eunice="$undef"
  286.     echo "exit 1" >eunice
  287. fi
  288. chmod 755 bsd usg v7 eunice
  289. $eunicefix bsd usg v7 eunice
  290.  
  291. : see if sh knows # comments
  292. echo " "
  293. echo "Checking your sh to see if it knows about # comments..."
  294. if sh -c '#' >/dev/null 2>&1 ; then
  295.     echo "Your sh handles # comments correctly."
  296.     shsharp=true
  297.     spitshell=cat
  298.     echo " "
  299.     echo "Okay, let's see if #! works on this system..."
  300.     echo "#!/bin/echo hi" > try
  301.     $eunicefix try
  302.     chmod 755 try
  303.     try > today
  304.     if test -s today; then
  305.     echo "It does."
  306.     sharpbang='#!'
  307.     else
  308.     echo "#! /bin/echo hi" > try
  309.     $eunicefix try
  310.     chmod 755 try
  311.     try > today
  312.     if test -s today; then
  313.         echo "It does."
  314.         sharpbang='#! '
  315.     else
  316.         echo "It doesn't."
  317.         sharpbang=': use '
  318.     fi
  319.     fi
  320. else
  321.     echo "Your sh doesn't grok # comments--I will strip them later on."
  322.     shsharp=false
  323.     echo "exec grep -v '^#'" >spitshell
  324.     chmod 755 spitshell
  325.     $eunicefix spitshell
  326.     spitshell=`pwd`/spitshell
  327.     echo "I presume that if # doesn't work, #! won't work either!"
  328.     sharpbang=': use '
  329. fi
  330.  
  331. : figure out how to guarantee sh startup
  332. echo " "
  333. echo "Checking out how to guarantee sh startup..."
  334. startsh=$sharpbang'/bin/sh'
  335. echo "Let's see if '$startsh' works..."
  336. cat >try <<EOSS
  337. $startsh
  338. set abc
  339. test "$?abc" != 1
  340. EOSS
  341.  
  342. chmod 755 try
  343. $eunicefix try
  344. if try; then
  345.     echo "Yup, it does."
  346. else
  347.     echo "Nope.  You may have to fix up the shell scripts to make sure sh runs them."
  348. fi
  349. rm -f try today
  350.  
  351. : find out where common programs are
  352. echo " "
  353. echo "Locating common programs..."
  354. pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib"
  355. cat <<EOSC >loc
  356. $startsh
  357. thing=\$1
  358. shift
  359. dflt=\$1
  360. shift
  361. for dir in \$*; do
  362.     case "\$thing" in
  363.     .)
  364.     if test -d \$dir/\$thing; then
  365.         echo \$dir
  366.         exit 0
  367.     fi
  368.     ;;
  369.     *)
  370.     if test -f \$dir/\$thing; then
  371.         echo \$dir/\$thing
  372.         exit 0
  373.     fi
  374.     ;;
  375.     esac
  376. done
  377. echo \$dflt
  378. exit 1
  379. EOSC
  380. chmod 755 loc
  381. $eunicefix loc
  382. loclist="
  383. expr
  384. sed
  385. echo
  386. cat
  387. rm
  388. grep
  389. "
  390. trylist="
  391. test
  392. Mcc
  393. "
  394. for file in $loclist; do
  395.     xxx=`loc $file $file $pth`
  396.     eval $file=$xxx
  397.     case "$xxx" in
  398.     /*)
  399.     echo $file is in $xxx.
  400.     ;;
  401.     *)
  402.     echo "I don't know where $file is.  I hope it's in everyone's PATH."
  403.     ;;
  404.     esac
  405. done
  406. echo " "
  407. echo "Don't worry if any of the following aren't found..."
  408. ans=offhand
  409. for file in $trylist; do
  410.     xxx=`loc $file $file $pth`
  411.     eval $file=$xxx
  412.     case "$xxx" in
  413.     /*)
  414.     echo $file is in $xxx.
  415.     ;;
  416.     *)
  417.     echo "I don't see $file out there, $ans."
  418.     ans=either
  419.     ;;
  420.     esac
  421. done
  422. case "$egrep" in
  423. egrep)
  424.     echo "Substituting grep for egrep."
  425.     egrep=$grep
  426.     ;;
  427. esac
  428. case "$test" in
  429. test)
  430.     echo "Hopefully test is built into your sh."
  431.     ;;
  432. /bin/test)
  433.     echo " "
  434.     echo $n 'Is your "test" built into sh? [n] (OK to guess) '"$c"
  435.     rp='test built into sh? [n]'
  436.     . myread
  437.     case "$ans" in
  438.     y*) test=test ;;
  439.     esac
  440.     ;;
  441. *)
  442.     test=test
  443.     ;;
  444. esac
  445. case "$echo" in
  446. echo)
  447.     echo "Hopefully echo is built into your sh."
  448.     ;;
  449. /bin/echo)
  450.     echo " "
  451.     echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
  452.     $echo $n "hi there$c" >foo1
  453.     echo $n "hi there$c" >foo2
  454.     if cmp foo1 foo2 >/dev/null 2>&1; then
  455.     echo "They are compatible.  In fact, they may be identical."
  456.     else
  457.     echo "They are not compatible--the echo builtin will be used."
  458.     echo=echo
  459.     fi
  460.     $rm -f foo1 foo2
  461.     ;;
  462. *)
  463.     echo=echo
  464.     ;;
  465. esac
  466.  
  467. : index or strcpy
  468. $echo " "
  469. if $contains index libc.list >/dev/null 2>&1 ; then
  470.     $echo "Your system appears to use index() and rindex() rather than strchr()"
  471.     $echo $n "and strrchr().  Is this correct? [y] $c"
  472.     rp='index() rather than strchr()? [y]'
  473.     . myread
  474.     case "$ans" in
  475.     n*|f*) d_index="$define" ;;
  476.     *)     d_index="$undef" ;;
  477.     esac
  478. else
  479.     $echo "Your system appears to use strchr() and strrchr() rather than index()"
  480.     $echo $n "and rindex().  Is this correct? [y] $c"
  481.     rp='strchr() rather than index()? [y]'
  482.     . myread
  483.     case "$ans" in
  484.     n*|f*) d_index="$undef" ;;
  485.     *)     d_index="$define" ;;
  486.     esac
  487. fi
  488.  
  489. : check for void type
  490. $echo " "
  491. $echo "Checking to see if your C compiler groks the void type..."
  492. $cat >try.c <<'EOCP'
  493. void main();
  494. EOCP
  495. if cc -c try.c >/dev/null 2>&1 ; then
  496.     d_void="$undef"
  497.     $echo "Yup, it does."
  498. else
  499.     d_void="$define"
  500.     $echo "Nope, it doesn't (boo hiss).  I will substitute int."
  501. fi
  502. $rm -f try.*
  503.  
  504. : see how we invoke the C preprocessor
  505. echo " "
  506. echo "Checking to see how your C preprocessor is invoked..."
  507. cat <<'EOT' >testcpp.c
  508. #define ABC abc
  509. #define XYZ xyz
  510. ABC.XYZ
  511. EOT
  512. echo 'Maybe "cc -E" will work...'
  513. cc -E testcpp.c >testcpp.out 2>&1
  514. if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
  515.     echo "Yup, it does."
  516.     cpp='cc -E'
  517. else
  518.     echo 'Nope...maybe "cc -P" will work...'
  519.     cc -P testcpp.c >testcpp.out 2>&1
  520.     if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
  521.     echo "Yup, that does."
  522.     cpp='cc -P'
  523.     else
  524.     echo 'Nixed again...maybe "/lib/cpp" will work...'
  525.     /lib/cpp testcpp.c >testcpp.out 2>&1
  526.     if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
  527.         echo "Hooray, it works!  I was beginning to wonder."
  528.         cpp='/lib/cpp'
  529.     else
  530.         echo 'Hmm...maybe you already told me...'
  531.         case "$cpp" in
  532.         '') ;;
  533.         *) $cpp testcpp.c >testcpp.ou component. */
  534. X    if (chdir(p) < 0 && mkdir(p, 0777) < 0 && chdir(p) < 0)
  535. X        Quit("Cannot chdir nor mkdir desired directory");
  536. X    }
  537. X    else
  538. X    cwd[0] = '\0';
  539. X
  540. X    /* No buffering. */
  541. X    (void)setbuf(stdout, (char *)NULL);
  542. X    (void)setbuf(stderr, (char *)NULL);
  543. X
  544. X    if (*av)
  545. X    /* Process filenames from command line. */
  546. X    for (; *av; av++) {
  547. X        if (cwd[0] && av[0][0] != '/') {
  548. X        (void)sprintf(buff, "%s/%s", cwd, *av);
  549. X        *av = buff;
  550. X        }
  551. X        if ((Stream = fopen(*av, "r")) == NULL)
  552. X        Fprintf(stderr, "unshar:  Can't open file '%s'.\n", *av);
  553. X        else {
  554. X        Unshar(*av, HdrFile, Stream, Saveit, Forced);
  555. X        (void)fclose(Stream);
  556. X        }
  557. X    }
  558. X    else
  559. X    /* Do standard input. */
  560. X    Unshar((char *)NULL, HdrFile, stdin, Saveit, Forced);
  561. X
  562. X    /* That's all she wrote. */
  563. X    exit(0);
  564. X}
  565. SHAR_EOF
  566. if test 8368 -ne "`wc -c < 'unshar.c'`"
  567. then
  568.     echo shar: error transmitting "'unshar.c'" '(should have been 8368 characters)'
  569. fi
  570. fi # end of overwriting check
  571. echo shar: extracting "'unshar.man'" '(2326 characters)'
  572. if test -f 'unshar.man'
  573. then
  574.     echo shar: will not over-write existing file "'unshar.man'"
  575. else
  576. sed 's/^X//' << \SHAR_EOF > 'unshar.man'
  577. X.TH UNSHAR 1l
  578. X.\" $Header: unshar.man,v 2.0 88/05/27 13:29:02 rsalz Exp $
  579. X.SH NAME
  580. Xunshar \- unpack shell archives from news, mail, notes, etc.
  581. X.SH SYNOPSIS
  582. X.B unshar
  583. X[
  584. X.BI \-c\| directory
  585. X] [
  586. X.BI \-d\| directory
  587. X] [
  588. X.BI \-h\| file
  589. X] [
  590. X.B \-f
  591. X] [
  592. X.B \-n
  593. X] [
  594. X.B \-s
  595. X] [ file... ]
  596. X.SH DESCRIPTION
  597. X.I Unshar
  598. Xremoves mail and news header lines from its input, and feeds the remainder
  599. Xto
  600. X.IR /bin/sh (1)
  601. Xso that a shell archive can be properly unpacked.
  602. XIf no files are specified,
  603. X.I unshar
  604. Xreads from standard input.
  605. XThe program is designed to be useful when unpacking archives directly
  606. Xfrom the news or mail systems (e.g., s | unshar).
  607. X.PP
  608. X.I Unshar
  609. Xnormally unpacks its files in the current directory.
  610. XUse the ``\-c'' option to have the program change to a new directory
  611. Xbefore invoking the shell.
  612. XIf the directory does not exist, it will try to create it.
  613. XIf the directory name starts with a question mark, then
  614. X.I unshar
  615. Xwill ask for the directory name before doing anything; this is most useful
  616. Xwith the environment variable UNSHAREDIR.
  617. XIf the directory name starts with a tilde, then the value of the HOME
  618. Xenvironment variable is inserted in place of that character.
  619. XFor convenience, the ``\-d'' option is a synonym for the ``\-c'' option.
  620. X.PP
  621. X.I Unshar
  622. Xnormally complains if the input looks like something other than a shar file.
  623. X(Among other things, it checks for files that resemble C, and Pascal code).
  624. XIt can be fooled, however, by nonstandard versions of news, notes, etc.
  625. XThe ``\-f'' option forces
  626. X.I unshar
  627. Xto try unpacking files, even if they look like something else.
  628. X.PP
  629. XDepending on how the program is installed,
  630. X.I unshar
  631. Xmay or may not try to preserve the header part of file ``foo''
  632. Xinto the name ``foo.hdr'' (if the file is standard input, the name
  633. Xwill be ``UNSHAR.HDR'').
  634. XUsing the ``\-s'' option forces the program to save the headers, while
  635. Xusing the ``\-n'' option forces it to discard the headers.
  636. XThe file is appended to, if it already exists, so all headers can be easily
  637. Xsaved in one file.
  638. XThe name of the file may be given by using the ``\-h'' option; this is
  639. Xparticularly useful when processing more than one file at a time.
  640. X.SH ENVIRONMENT
  641. X.ta \w'UNSHAREDIR  'u
  642. XHOME    Value used if a leading tilde is given in directory name.
  643. X.br
  644. XUNSHAREDIR    Default value for ``\-c'' option.
  645. X.SH SEE ALSO
  646. Xshar(1).
  647. SHAR_EOF
  648. if test 2326 -ne "`wc -c < 'unshar.man'`"
  649. then
  650.     echo shar: error transmitting "'unshar.man'" '(should have been 2326 characters)'
  651. fi
  652. fi # end of overwriting check
  653. #    End of shell archive
  654. exit 0
  655. tr.t_lab, TEXT);
  656. -}
  657. -
  658. -/*
  659. - *    Print out data.
  660. - */
  661. -
  662. -void    pdata(fid)
  663. -register  ef_fid  fid;
  664. -{
  665. -    register  long    dpos, endd;
  666. -    register  int    lng;
  667. -    unsigned  ctyp;
  668. -    int    had, par, inc;
  669. -    char    *msg;
  670. -    d_entry    dstr;
  671. -    
  672. -    (void) printf("\n.data\n");
  673. -    
  674. -    dpos = fid->ef_dbase;
  675. -    endd = dpos + fid->ef_dsize;
  676.